package pers.jason.wppm.edge.web.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.social.connect.web.ProviderSignInUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.ServletWebRequest;
import pers.jason.wppm.auth.api.entity.User;
import pers.jason.wppm.edge.web.web.service.UserService;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName: UserController
 * @Author: JZH
 * @Date: 2018/12/2 21:21
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @Autowired
    private ProviderSignInUtils providerSignInUtils;



    @PostMapping("social/bind")
    public void socialBindingUser(String mobile, HttpServletRequest request) {
        User user = userService.findOrCreateUserByMobile(mobile);
        providerSignInUtils.doPostSignUp(user.getUserId(), new ServletWebRequest(request));
    }

}
